import {lazy} from "react";
import deepClone from "./deepClone.js";

const toRightRouter = (routes) => {
    const newRoutes = deepClone(routes)
    function switchRouter(routes){
        for (const item of routes) {
            item.component = lazy(() => import( /* @vite-ignore */ item.componentPath))
            if (item.children.length > 0) {
                switchRouter(item.children)
            }
        }
    }
    switchRouter(newRoutes)
    return newRoutes;
}
export default toRightRouter;